package com.li.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * 订单界面  地址底部
 * Created by Li on 2016/8/25.
 */
public class ViewBottom extends View {
    public ViewBottom(Context context) {
        this(context, null);
    }

    public ViewBottom(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public ViewBottom(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
        init();
    }
    private Paint paint1,paint2;
    private int width,height,singleWidth;
    private void init() {
        paint1 = new Paint();
        paint1.setColor(Color.RED);
        paint1.setAntiAlias(true);
        paint2 = new Paint();
        paint2.setColor(Color.LTGRAY);
        paint2.setAntiAlias(true);


    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        width = getMeasuredWidth();
        height = getMeasuredHeight();
        paint1.setStrokeWidth(height);
        paint2.setStrokeWidth(height);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        singleWidth = width/30;
        canvas.skew(1.5f,0f);
        for (int i = 0 ;i<30;i++){
            if (i%2==0){
                canvas.drawRect(i*singleWidth,0,i*singleWidth+singleWidth,height,paint1);
            }else {
                canvas.drawRect(i*singleWidth,0,i*singleWidth+singleWidth,height,paint2);
            }
        }
    }
}
